
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutterxc/module/common_module.dart';
import 'package:flutterxc/widget/webview.dart';
class LocalNav extends StatelessWidget {
  final List<CommonModel> localNavList;
  final String name;
  LocalNav({@required this.localNavList,this.name = 'xiaoming'});
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
          decoration: BoxDecoration(
            borderRadius:BorderRadius.circular(8),
            color: Colors.white,
          ),
          child:
          Padding(padding: EdgeInsets.all(12),child: _items(context),)
    );
  }

  _items (BuildContext context){
    if (localNavList == null) return null;
    List<Widget> list = [];
    localNavList.forEach((module){
        list.add(_item(context, module));
    });
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: list,
    );
  }
  _item (BuildContext context, module) {
    return GestureDetector(
      onTap: (){
        Navigator.push(context, MaterialPageRoute(builder: (context) =>
        WebView(url: module.url,statusBarColor: module.statusBarColor,hideAppBar:module.hideAppBar)
        ));
      },
      child: Column(
        children: <Widget>[
          Image.network(module.icon,width: 46,height: 46,),
          SizedBox(height: 6,),
          Text(module.title,style: TextStyle(fontSize: 12),)
        ],
      ),
    );
  }
}